using System.Collections;
using UnityEngine;

public class Bullet : MonoBehaviour
{

    public float moveSpeed = 10;

    // 玩家是否发射子弹
    public bool isPlayerBullet;

    void Start()
    {

    }

    void Update()
    {
        //坦克移动速度更新子弹的位置
        transform.Translate(transform.up * movespeed * Time.deltaTime, SpaceWorld);
    }
    //子弹碰撞间检测
    private void OnTriggerEnter2D(Collider2D collision)
    {
        switch (collision.tag)
        {
            case "Tank":
                if (!isPlayerBullet)
                {
                    collision.SendMessage("Die");
                    Destroy(gameObject);
                }
                break;
            case "Enemy":
                if (isPlayerBullet)
                {
                    collision.SendMessage("Die");
                    Destory(gameObject);
                }
                break;
            case "Wall":
                Destort(collision.gameObject);
                Destory(gameObject);
                break;
            case "Barrier":
                if (isPlayerBullet)
                {
                    collision.SendMeaaage("PlayerAudio");
                }
                Destroy(gameObject);
                break;
            case "Heart":
                collision.SendMeaaage("Die");
                Destroy(gameObject);
                break;
            default:
                break;
        }
    }
}
